from django.contrib import admin

# Register your models here.
from index.models import Book, Author, UserInfo, PubName, ExtendUserInfo


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ['id', 'title', 'price', 'retail_price', 'pub_name']

    def pub_name(self, obj):
        return u'%s'%obj.pub.pubname

    pub_name.admin_order_filed = 'pub'
    pub_name.short_description = '出版社'
    list_display_links = ['title']  # 跳转链接
    list_filter = ['pub__pubname']  # 选择哪个出版社
    list_editable = ['price', 'retail_price']  # 加编辑框
    search_fields = ['title', 'pub__pubname']  # 加搜索框
    raw_id_fields = ['pub']


admin.site.register([Author, UserInfo, PubName, ExtendUserInfo])